package com.cloud.drore.eboss.supplier.mapper.provider;

import com.cloud.drore.eboss.supplier.entity.CollocationProduct;
import org.apache.commons.lang.StringUtils;

/**
 * 浙江卓锐科技股份有限公司 版权所有  Copyright 2018<br>
 *
 * @Description: <br>
 * @Project: eboos <br>
 * @CreateDate: Created in 2018/2/5 19:14 <br>
 * @Author: <a href="575842778@qq.com">郑永涛</a>
 */
public class CollocationProductProvider {

    public CollocationProductProvider(){

    }

    private static String selectCollocationProductByParamSql = "select id,dic_code,name,product_id,product_type " +
            " from eboos_collocation_product where is_deleted = '0' ";

    public String updateByParam(CollocationProduct collocationProduct){
        String sql = "update eboos_collocation_product set ";
        if(StringUtils.isNotBlank(collocationProduct.getState()))
            sql += " state ='"+ collocationProduct.getState()+"'" ;
        sql += " where id=" + collocationProduct.getId();
        return sql;
    }


    public String selectCollocationProductByParam(CollocationProduct collocationProduct){
        String sql = selectCollocationProductByParamSql;
        if(StringUtils.isNotBlank(collocationProduct.getProductType()))
            sql += " and product_type = '" + collocationProduct.getProductType() + "'";
        if(collocationProduct.getProductId() != null)
            sql += " and product_id = " + collocationProduct.getProductId() + "";
        if(StringUtils.isNotBlank(collocationProduct.getState()))
            sql += " and state = '" + collocationProduct.getState() + "'";
        return sql;
    }
}